package com.tfjybj.itoo.exam.provider.service.impl;

import com.dmsdbj.itoo.tool.base.service.impl.BaseServicePlusImpl;
import com.dmsdbj.itoo.tool.business.ItooResult;
import com.dmsdbj.itoo.tool.constantutil.YearSemester;
import com.tfjybj.itoo.exam.entity.TeachClassEntity;
import com.tfjybj.itoo.exam.provider.dao.TeachClassDao;
import com.tfjybj.itoo.exam.provider.service.TeachClassService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * TeachClassService接口实现类
 * ${base}表
 *
 * @author 郭满亮
 * @version 2.0.0
 * @since 2.0.0 2019-02-09 19:43:37
 */
@Service("teachClassService")
public class TeachClassServiceImpl extends BaseServicePlusImpl<TeachClassDao, TeachClassEntity> implements TeachClassService {
	
	//region 模板生成
    @Resource
    private TeachClassDao teachClassDao;

    //endregion

    /* **********************************以下为非模板生成的内容********************************* */
    /**
     * 根据教师id、上课班名称和课程id查找TeachClass
     *
     * @param teacherId 教师id
     * @param teachClassName 上课班名称
     * @param courseId 课程id
     * @return 根据教师id和上课班名称查找的结果
     * @author 郭满亮
     * @since 2.0.0 2019-02-09 19:43:37
     */
    @Override
    public ItooResult getByTeachClassName(String teacherId, String teachClassName, String courseId) {
        String semester = YearSemester.getYearSemesterCode(0, 0).get(0);
        int teachClass = teachClassDao.getByTeachClassName(teacherId,teachClassName,courseId,semester);
        if (teachClass == 0) {
            return ItooResult.build(ItooResult.SUCCESS,"可以添加此班课");
        }
        return ItooResult.build(ItooResult.FAIL,"已有此班课");
    }
}
